package com.xgz.service.impl;

import com.xgz.entity.TUser;
import com.xgz.dao.TUserDao;
import com.xgz.service.TUserService;

import com.xgz.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;

/**
 * (TUser)表服务实现类
 *
 * @author makejava
 * @since 2022-10-19 19:31:22
 */
@Service
public class TUserServiceImpl implements TUserService {

    @Autowired
    private TUserDao tUserDao;

    /**
     * 注册
     */
    @Override
    public boolean addUser(TUser tUser) {

        String uuid = UUID.randomUUID().toString();

        String newPassword = MD5Util.MD5EncodeUtf8(tUser.getPassword(), uuid);
        tUser.setPassword(newPassword);
        tUser.setSalt(uuid);
        int i = tUserDao.addUser(tUser);
        return i > 0 ? true : false;
    }

    /**
     * 根据用户名查询
     * @param username 筛选条件
     * @return
     */
    @Override
    public List<TUser> queryByName(String username) {
        return null;
    }

    @Override
    public List<TUser> queryAll() {
        return tUserDao.queryAll();
    }


}
